<?php
declare (strict_types=1);

namespace app\api\model;

use think\Model;

/**
 * @mixin \think\Model
 */
class User extends Model
{
    /*几个小时之内的查询*/
    static function inHour($h = 0)
    {
        $h = -1 * $h;
        return self::whereTime('create_time', "$h hours")->select()->toArray();
    }

    static function inMinutes($m = 0)
    {
        $m = -1 * $m;
        return self::whereTime('create_time', "$m minutes")->select()->toArray();
    }

    static function inTime($time = 'today')
    {
        $arr = ['today', 'yesterday', 'week', 'last week', 'month', 'last month', 'year', 'last year'];
        if (in_array($time, $arr)) {
            return User::whereTime('create_time', $time)->select()->toArray();
        }

    }
}
